<script setup lang="ts">
import { ref } from "vue";
import { formRules } from "./utils/rule";
import { FormProps } from "./utils/types";

const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    property_name: "",
    property_remark: "",
    family_id: 0
  })
});

const ruleFormRef = ref();
const newFormInline = ref(props.formInline);

function getRef() {
  return ruleFormRef.value;
}

defineExpose({ getRef });
</script>

<template>
  <el-form
    ref="ruleFormRef"
    :model="newFormInline"
    :rules="formRules"
    label-width="82px"
  >
    <el-form-item label="家庭名称：" prop="family_id">
      <el-select
        v-model="newFormInline.family_id"
        placeholder="请选择家庭名称："
        clearable
        class="!w-[180px]"
      >
        <el-option label="支出" value="1" />
        <el-option label="收入" value="2" />
      </el-select>
    </el-form-item>
    <el-form-item label="资产名称" prop="property_name">
      <el-input
        v-model="newFormInline.property_name"
        clearable
        placeholder="请输入资产名称"
      />
    </el-form-item>

    <el-form-item label="资产备注">
      <el-input
        v-model="newFormInline.property_remark"
        placeholder="请输入资产备注信息"
        type="textarea"
      />
    </el-form-item>
  </el-form>
</template>
